package com.pzhu.user.domain.dto.converter;

import com.pzhu.user.api.MenuApi;
import com.pzhu.user.domain.ro.MenuCreateRO;
import com.pzhu.user.domain.ro.MenuUpdateRO;
import com.pzhu.user.domain.vo.MenuSearchVO;
import org.mapstruct.*;

@Mapper(
        componentModel = MappingConstants.ComponentModel.SPRING,
        nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
        unmappedTargetPolicy = ReportingPolicy.IGNORE,
        collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED)
public interface MenuDtoConverter {

    MenuCreateRO convert(MenuApi.MenuCreateDTO menuDTO);

    MenuUpdateRO convertUpdate(MenuApi.MenuUpdateDTO menuUpdateDTO);

    @Mapping(target = "menuId", source = "id")
     @Mapping(target = "menuName", source = "menuName")
    @Mapping(target = "menuCode", source = "menuCode")
    @Mapping(target = "parentId", source = "parentId")
    @Mapping(target = "menuType", source = "type")
    @Mapping(target = "menuTags", source = "menuTagList")
    @Mapping(target = "meta", source = "meta")
    @Mapping(target = "createTime", source = "createTime")
    @Mapping(target = "updateTime", source = "updateTime")
    MenuApi.MenuDTO toDTO(MenuSearchVO menuSearchVO);
}